#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int delSubStr(char *src,char *sub,char *result)
{
        int i=0;
        int lsub=strlen(sub);
        int lsrc=strlen(src);
        int j=0;
        char *p=strchr(src,sub[0]);
        char *q[20]={0};
        char *p0;
        p0=src+lsrc;

        for(;;)
        {
                p = strchr(p,sub[0]);

                if(p==NULL) break;
                else if(strncmp(sub,p,lsub) ==0)
                {
                        p[0]='\0';
                        q[j++]=p+lsub;
                        p=p+lsub;

                        if(p>p0) break;
                }

                else p++;

        }
                result = strcat(src,q[0]);
                        for(i=1;i<j;i++)
                        {
                                result =strcat(result,q[i]);
                        }
	int s=strlen(result);
	for(i=0;i<=s;i++)
	{
		*(result + i) =*( q[i]);
	}


                return j;
}
int main()
{
        char src[13]="aabbcadeabcd";
                char sub[3]="ab";
                        char result[20]={0};
                        int b=delSubStr(src,sub,result);
printf("%d\n",b);
                        puts(result);

                        return 0;
}

